import { IParam, EntityBase } from '@/core';
import { ISys_component_api } from './interface/i-sys-component-api';
import Sys_component_apiKeys from './sys-component-api-keys';

/**
 * 组件使用接口基类
 * 基于template/src/api/{{appEntities}}/{{appEntities}}-base.ts.hbs生成
 *
 * @export
 * @abstract
 * @class Sys_component_apiBase
 * @extends { EntityBase }
 * @implements { ISys_component_api }
 */
export abstract class Sys_component_apiBase
	extends EntityBase
	implements ISys_component_api
{
	/**
	 * 实体名称
	 *
	 * @readonly
	 * @type {string}
	 * @memberof Sys_component_apiBase
	 */
	get srfdename(): string {
		return 'SYS_COMPONENT_API';
	}

	/**
	 * 当前实体所有属性
	 *
	 * @protected
	 * @type {string[]}
	 * @memberof Sys_component_apiBase
	 */
	protected get keys(): string[] {
		return Sys_component_apiKeys;
	}

	/**
	 * Creates an instance of ConstactOppoBase.
	 * @param {*} [data]
	 * @memberof Sys_component_apiBase
	 */
	constructor(data?: any) {
		super();
		this.setData(data);
	}

	get srfkey(): string {
		return this.id;
	}

	set srfkey(val: string) {
		this.id = val;
	}

	get srfmajortext(): string {
		return this.id;
	}

	set srfmajortext(val: string) {
		this.id = val;
	}
	/**
	 * 标识
	 **/
	id?: any;

	/**
	 * 组件标识
	 **/
	component_id?: any;

	/**
	 * 接口方法标识
	 **/
	api_operation_id?: any;

	/**
	 * 显示名
	 **/
	display_name?: any;

	/**
	 * 重置实体数据
	 *
	 * @param {IParam} [data={}]
	 * @memberof Sys_component_apiBase
	 */
	reset(data: IParam = {}): void {
		super.reset(data);
		this.id = data.id || data.srfkey;
		this.id = data.id || data.srfmajortext;
	}
}
